package com.cyq.order.controller;

import com.cyq.order.pojo.Order;
import com.cyq.order.server.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.naming.event.ObjectChangeListener;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private OrderService orderService;

    @GetMapping("/add")
    public String add() {
        Order order = new Order();
        order.setProductId(9);
        order.setStatus(0);
        order.setTotalAmount(100);
        orderService.create(order);

        return "ok";
    }

    @GetMapping("/selectAll")
    public List<Order> selectAll() {
        return orderService.selectAll();
    }

}
